/**
 * @Author: Sun Rising
 * @Date: 2020-07-02 08:23:49
 * @Last Modified by: Sun Rising
 * @Last Modified time: 2020-07-02 08:24:12
 * @Description: 抽象工厂模式
 */
// ui处理器
interface UiHandle {
    handle()
}

// 安卓ui处理器
class AndroinUiHandle implements UiHandle {

    handle() {
        console.log("i am Androin UiHandle");
    }

}

// iOS ui处理器
class IosUiHandle implements UiHandle {

    handle() {
        console.log("i am Ios UiHandle");
    }

}

// 操作处理器
interface OperationHandle {
    remove()
}

// 安卓操作处理器
class AndroinOperationHandle implements OperationHandle {

    remove() {
        console.log("i am Androin OperationHandle");
    }

}

// IOS操作处理器
class IosOperationHandle implements OperationHandle {

    remove() {
        console.log("i am Ios OperationHandle");
    }

}

// 抽象工厂
abstract class AbstractFactory {
    abstract getUiHandle()
    abstract getOperationHandle()
}

// 安卓工厂
class AndroinFactory extends AbstractFactory {

    getUiHandle() {
        return new AndroinUiHandle()
    }
    getOperationHandle() {
        return new AndroinOperationHandle()
    }

}

// ios工厂
class IosFactory extends AbstractFactory {

    getUiHandle() {
        return new IosUiHandle()
    }
    getOperationHandle() {
        return new IosOperationHandle()
    }

}

let androinFactory = new AndroinFactory()
androinFactory.getUiHandle().handle()
androinFactory.getOperationHandle().remove()

let iosFactory = new IosFactory()
iosFactory.getUiHandle().handle()
iosFactory.getOperationHandle().remove()